
<template>
  <div class="app">
    <div class="tipinfo" v-show="isTip">{{tipword}}</div>

    <topbar/>
  <personbar/>
    <div class="container" >
      <div class="leftpart bg-ffffff">
       <div class="hmenu">
         <nuxt-link to='/person/collect'> 我的收藏</nuxt-link>
         <nuxt-link  to='/person/exchange'> 交易记录</nuxt-link>
         <nuxt-link class="on" to='/person/setup'> 账号设置</nuxt-link>
       </div>

        <div class="list66">
          <div class="aa">
            <div class="a1">密码</div>
            <div class="a2">{{pwdstate}}</div>
          </div>
          <div class="bb hand" @click="setPassword">编辑</div>
        </div>
        <div class="list66">
          <div class="aa">
            <div class="a1">绑定手机</div>
            <div class="a2">{{bindmobile}}</div>
          </div>
          <div class="bb hand" @click="bindPhone">编辑</div>
        </div>
        <div class="list66">
          <div class="aa">
            <div class="a1">绑定邮箱</div>
            <div class="a2">{{unbundemail}}</div>
          </div>
          <div class="bb hand" @click="bindEmail">编辑</div>
        </div>

        <div class="list147">
          <div class="w1">绑定第三方账号</div>
          <div class="w2">
            <span class="" style="cursor:pointer" @click='getQrCode(1)'><img src="../../assets/images/icon-weixin.png" height="27" width="35" alt=""> {{unbundwx}}微信</span>
            <span class="" style="cursor:pointer" @click='getQrCode(3)'><img src="../../assets/images/icon-weibo.png" height="27" width="27" alt=""> {{unbundwb}}微博</span>
            <span class="" style="cursor:pointer" @click='getQrCode(2)'><img src="../../assets/images/icon-qq.png" height="27" width="27" alt=""> {{unbundqq}}QQ</span>
          </div>
        </div>



      </div>

<!-- 左右分离-->
      <div class="rightpart">
          <Personright/>
       </div>
     </div>
      <div class="gap100"></div>

<!-- 设置密码 -->

<div class="mask" v-show="isSetPassword">
    <div class="forgetbox" >
      <div class="close" @click="closeWindow"></div>
      <div class="fftitle">设置密码</div>
      <div class="ffdec">已设置</div>
       <div class="ffbox">
          <input type="password" class="ffinputtext" v-model="newpass" maxlength="10" placeholder="新密码（8位以上数字和字母）">
       </div>
      <div class="ffbox">
        <input type="password" class="ffinputtext" v-model="newpassagain" maxlength="10" placeholder="再次输入新密码">
      </div>
      <div class="ffnextbtn hand" @click="goSetPass">提交</div>
    </div>
</div>

    <!-- 之前未绑定手机 -->
    <div class="mask" v-show="isBindPhone">
      <div class="forgetbox" >
        <div class="close" @click="closeWindow"></div>
        <div class="fftitle">绑定手机</div>
        <div class="ffdec">未绑定</div>
        <div class="ffbox">
          <input type="text" class="ffinputtext" v-model="phone_unbind" placeholder="输入绑定的手机号">
        </div>
        <div class="ffbox">
          <input type="text" class="ffinputtext" v-model="phonecode_unbind" maxlength="6" placeholder="请输入6位短信验证码">
          <div class="ffyanzheng hand">发送验证码</div>
        </div>
        <div class="ffnextbtn hand" @click="goBindPhone">绑 定</div>
      </div>
    </div>

<!-- 已经绑定过手机号 -->
<!--<div class="mask" v-show="updatePhone">-->
<!--&lt;!&ndash; 第一步验证&ndash;&gt;-->
    <!--<div class="forgetbox" v-show="phonestep1">-->
      <!--<div class="close" @click="closeWindow"></div>-->
      <!--<div class="fftitle">身份验证</div>-->
      <!--<div class="ffdec">为了保护你的账号安全，请验证身份，验证成功后进行下一步操作</div>-->
       <!--<div class="ffbox">-->
         <!--<div class="ffinputtext">136****5569</div>-->
       <!--</div>-->
      <!--<div class="ffbox">-->
        <!--<input type="text" class="ffinputtext" v-model="phonecode" maxlength="6" placeholder="请输入6位验证码">-->
         <!--<div class="ffyanzheng hand">发送验证码</div>-->
      <!--</div>-->
      <!--<div class="ffnextbtn hand" @click="updatePhone1">验证</div>-->
    <!--</div>-->

  <!-- 已经绑定过手机号 -->
  <div class="mask" v-show="updatePhone">
    <!-- 第一步验证-->
    <div class="forgetbox" v-show="phonestep1">
      <div class="close" @click="closeWindow"></div>
      <div class="fftitle">验证手机号</div>
      <div class="ffdec">验证码将会发送至你的注册邮箱或手机</div>
      <div class="ffbox">
        <div class="ffinputtext">{{bindmobile}}</div>
      </div>
      <div class="ffbox">
        <input type="text" class="ffinputtext" v-model="phonecode" maxlength="6" placeholder="请输入6位验证码">
        <div class="ffyanzheng hand" v-show="sendAuthCode4" @click="sendCode(5)">发送验证码</div>
        <div class="ffyanzheng hand" v-show="!sendAuthCode4" > <span class="auth_text_blue">{{auth_time}} </span> 秒后重新发送</div>

      </div>
      <div class="ffnextbtn hand" @click="updatePhone1">验证</div>
    </div>

<!-- 第二步更新   -->

    <!-- 第二步更新   -->
    <div class="forgetbox" v-show='phonestep2'>
      <div class="close" @click="closeWindow"></div>
      <div class="fftitle">更换手机号</div>
      <div class="ffdec">{{bindmobile}}</div>
      <div class="ffbox">
        <input type="text" class="ffinputtext" v-model="phone_bind" placeholder="输入要改绑定的手机号">
      </div>
      <div class="ffbox">
        <input type="text" class="ffinputtext" v-model="phonecode_bind" maxlength="6" placeholder="请输入6位验证码">
        <div class="ffyanzheng hand" v-show="sendAuthCode3" @click="sendCode(6)">发送验证码</div>
        <div class="ffyanzheng hand" v-show="!sendAuthCode3" > <span class="auth_text_blue">{{auth_time}} </span> 秒后重新发送</div>

      </div>
      <div class="ffnextbtn hand" @click="updatePhone2">绑 定</div>
    </div>
  </div>

<!--&lt;!&ndash; 之前没有绑定邮箱 &ndash;&gt;-->
<!--<div class="mask" v-show="isBindEmail">-->
    <!--<div class="forgetbox" >-->
      <!--<div class="close" @click="closeWindow"></div>-->
      <!--<div class="fftitle">绑定邮箱</div>-->
      <!--<div class="ffdec">未绑定</div>-->
       <!--<div class="ffbox">-->
         <!--<input type="text" class="ffinputtext" v-model="email_unbind" placeholder="输入要绑定的邮箱">-->
       <!--</div>-->
      <!--<div class="ffbox">-->
        <!--<input type="text" class="ffinputtext" v-model="emailcode_unbind" maxlength="6" placeholder="请输入6位验证码">-->
         <!--<div class="ffyanzheng hand">发送验证码</div>-->
      <!--</div>-->
      <!--<div class="ffnextbtn hand" @click="goBindEmail">绑 定</div>-->
    <!--</div>-->
 <!--</div>-->
    <div class="mask" v-show="isBindEmail">
      <div class="forgetbox" >
        <div class="close" @click="closeWindow"></div>
        <div class="fftitle">绑定邮箱</div>
        <div class="ffdec">{{unbundemail}}</div>
        <div class="ffbox">
          <input type="text" class="ffinputtext" v-model="email_unbind" placeholder="输入要绑定的邮箱">
        </div>
        <div class="ffbox">
          <input type="text" class="ffinputtext" v-model="emailcode_unbind" maxlength="6" placeholder="请输入6位验证码">
          <div class="ffyanzheng hand" @click="sendEmailCode(1)" v-show="sendAuthCode" >发送验证码</div>
          <div class="ffyanzheng hand" v-show="!sendAuthCode" > <span class="auth_text_blue">{{auth_time}} </span> 秒后重新发送</div>

        </div>
        <div class="ffnextbtn hand" @click="goBindEmail">绑 定</div>
      </div>
    </div>

<!-- 已经绑定过邮箱 -->
<div class="mask" v-show="updateEmail">
<!-- 第一步验证-->
    <div class="forgetbox" v-show="emailstep1">
      <div class="close" @click="closeWindow"></div>
      <div class="fftitle">身份验证</div>
      <div class="ffdec">为了保护你的账号安全，请验证身份，验证成功后进行下一步操作</div>
       <div class="ffbox">
         <div class="ffinputtext">{{unbundemail}}</div>
       </div>
      <div class="ffbox">
        <input type="text" class="ffinputtext" v-model="emailcode" maxlength="6" placeholder="请输入6位验证码">
         <div class="ffyanzheng hand" @click="sendEmailCode(2)" v-show="sendAuthCode1">发送验证码</div>
        <div class="ffyanzheng hand" v-show="!sendAuthCode1" > <span class="auth_text_blue">{{auth_time}} </span> 秒后重新发送</div>

      </div>
      <div class="ffnextbtn hand" @click="updateEmail1">验证</div>
    </div>

<!-- 第二步更新   -->
    <div class="forgetbox" v-show='emailstep2'>
      <div class="close" @click="closeWindow"></div>
      <div class="fftitle">绑定邮箱</div>
      <div class="ffdec">{{unbundemail}}</div>
       <div class="ffbox">
         <input type="text" class="ffinputtext" v-model="email_bind" placeholder="输入要绑定的邮箱">
       </div>
      <div class="ffbox">
        <input type="text" class="ffinputtext" v-model="emailcode_bind" maxlength="6" placeholder="请输入6位验证码">
         <div class="ffyanzheng hand" @click="sendEmailCode(3)" v-show="sendAuthCode2">发送验证码</div>
        <div class="ffyanzheng hand" v-show="!sendAuthCode2" > <span class="auth_text_blue">{{auth_time}} </span> 秒后重新发送</div>

      </div>
      <div class="ffnextbtn hand" @click="updateEmail2">绑 定</div>
    </div>
 </div>


<!-- 第三方绑定解除 -->

<!--<div class="mask" v-show="unbind3">-->
    <!--<div class="jb3" >-->
      <!--<div class="jbtitle">解绑社交账号</div>-->
      <!--<div class="jbdec">解绑微信后你将无法使用微信登录龙源文库，你确定?</div>-->

      <!--<div class="jbbtn">-->
        <!--<div class="a1 hand" @click='closeWindow'>暂不解绑</div>-->
        <!--<div class="a2 hand" @click="goUnbind">解绑</div>-->
      <!--</div>-->
    <!--</div>-->
 <!--</div>-->

    <div class="mask" v-show="unbindwx">
      <div class="jb3" >
        <div class="jbtitle">解绑社交账号</div>
        <div class="jbdec">解绑微信后你将无法使用微信登录龙源文库，你确定?</div>

        <div class="jbbtn">
          <div class="a1 hand" @click='closeWindow(1)'>暂不解绑</div>
          <div class="a2 hand" @click="goUnbind(1)">解绑</div>
        </div>
      </div>
    </div>
    <div class="mask" v-show="unbindqq">
      <div class="jb3" >
        <div class="jbtitle">解绑社交账号</div>
        <div class="jbdec">解绑qq后你将无法使用qq登录龙源文库，你确定?</div>

        <div class="jbbtn">
          <div class="a1 hand" @click='closeWindow(2)'>暂不解绑</div>
          <div class="a2 hand" @click="goUnbind(2)">解绑</div>
        </div>
      </div>
    </div>
    <div class="mask" v-show="unbindwb">
      <div class="jb3" >
        <div class="jbtitle">解绑社交账号</div>
        <div class="jbdec">解绑微博后你将无法使用微博登录龙源文库，你确定?</div>

        <div class="jbbtn">
          <div class="a1 hand" @click='closeWindow(3)'>暂不解绑</div>
          <div class="a2 hand" @click="goUnbind(3)">解绑</div>
        </div>
      </div>
    </div>


    <Bottombar/>
  </div>
</template>

<script>
import Topbar from '~/components/Topbar.vue'
import Personbar from '~/components/Personbar.vue'
import Personright from '~/components/Personright.vue'
import Bottombar from '~/components/Bottombar.vue'
import axios from 'axios'
import qs from 'qs'
export default {
  components: {
    Topbar,
    Bottombar,
    Personbar,
    Personright
  },
  data(){
    return{
      isShare:false,
      isSetPassword:false,
      newpass:'',
      newpassagain:'',

      havephone:true,
      haveemail:false,

      unbind3:false,

      isBindPhone:false,
      updatePhone:false,
      phonecode_unbind:'',
      phone_unbind:'',
      phonecode:'',
      phone_bind:'',
      phonecode_bind:'',
      phonestep1:false,
      phonestep2:false,

      isBindEmail:false,
      updateEmail:false,
      emailcode_unbind:'',
      emailcode:'',
      emailcode_bind:'',
      email_unbind:'',
      email_bind:'',
      emailstep1:false,
      emailstep2:false,
      pwdstate:'',
      user:'',
      bindmobile:'',
      unbindwx:false,
      unbindqq:false,
      unbindwb:false,
      unbundwx:'',
      unbundwb:'',
      unbundqq:'',
      unbundemail:'',
      // 提示
      isTip:false,
      tipword:'',
      unbind3:false,
      sendAuthCode:true,/*布尔值，通过v-show控制显示‘获取按钮’还是‘倒计时’ */
      auth_time: 0, /*倒计时 计数器*/
      sendAuthCode1:true,
      sendAuthCode2:true,
      sendAuthCode3:true,
      sendAuthCode4:true
    }
  },mounted(){

    //this.getSessionUser();
    this.user=JSON.parse(localStorage.getItem("user"));

    if(this.user!=null && this.user!="" && this.user!=undefined){
      this.loaddata();
    }else{
      this.$router.push({path: '/'});
    }

  },
  methods:{
    getSessionUser(){

      let key=localStorage.getItem("user_unique_code");
      if(key!=null && key!="" && key!=undefined){
        console.log("key "+key)
        axios.post('https://wenku.qikan.com:11000/admin/lib/getTokenByUserId.html',qs.stringify({'key':key})
        )
          .then((response)=>{
            console.log("resultuser "+response.data);
            let result= response.data;
            if(result.code==1){
              console.log(result.data.trim())
              this.user=JSON.parse(result.data.trim());
              console.info("usermsg "+this.user)
              console.log("user  "+this.user)
              if(this.user!=null && this.user!="" && this.user!=undefined){
                this.loaddata();
              }else{
                this.$router.push({path: '/'});
              }
            }else{
              this.$router.push({path: '/'});
            }
          })
          .catch((error)=>{
            console.log(error)
          })
      }else{
        this.$router.push({path: '/'});
      }


    },
    sendCode(type) {
      console.log("infosendcode");
      var mobilereg = /^1[345789]\d{9}$/;
      var phone='';
      if(type==6){
        if (this.phone_bind == null || this.phone_bind == "" || this.phone_bind == 'undefined') {
          this.tipshow("手机号不能为空!");
          return false;
        } else if (!mobilereg.test(this.phone_bind)) {
          this.tipshow("手机格式不正确");
          return false;
        }
        phone=this.phone_bind;

      }
      if(type==5){
        if (this.user.mobile == null || this.user.mobile == "" || this.user.mobile == 'undefined') {
          this.tipshow("手机号不能为空!");
          return false;
        } else if (!mobilereg.test(this.user.mobile)) {
          this.tipshow("手机格式不正确");
          return false;
        }
        phone=this.user.mobile;

      }
      console.log("phone "+phone)
      axios.post('https://wenku.qikan.com:11000/admin/lib/sendmsg.html',qs.stringify({'mobile':phone})
      )
        .then((response)=>{
          console.log(response.data);
          let result= response.data;
          if(result.code==1)
          {
            // this.tipshow("验证码发送成功");
            if(type==5){
              this.sendAuthCode4=false
            }
            if(type==6){
              this.sendAuthCode3=false

            }
            this.auth_time = 60;

            var auth_timetimer =  setInterval(()=>{
              this.auth_time--;
              if(this.auth_time<=0){
                if(type==5){
                  this.sendAuthCode4 = true;
                }
                if(type==6){
                  this.sendAuthCode3 = true;
                }


                clearInterval(auth_timetimer);
              }
            }, 1000);

          }else{
            this.tipshow(result.message)
          }
        })
        .catch((error)=>{
          console.log(error)
        })

    },
    //关闭窗口
    closeWindow(closetype){
      this.isSetPassword=false;
      this.isBindPhone=false;
      this.updatePhone=false;
      this.phonestep1=false;
      this.phonestep2=false;
      this.isBindEmail=false;
      this.updateEmail=false;
      this.emailstep1=false;
      this.emailstep2=false;
      if(closetype==1){
        this.unbindwx=false;

      }else if(closetype==2){
        this.unbindqq=false;
      }else if(closetype==3){
        this.unbindwb=false;
      }
    },sendEmailCode(type){
      let mailReg = /^([0-9A-Za-z\-_\.]+)@([0-9a-z\-]+\.[a-z]{2,3}(\.[a-z]{2})?)$/g;
      let email='';
      if(type==1){
        if(this.email_unbind==null && this.email_unbind=="" && this.email_unbind==undefined){
          this.tipshow("邮箱不为空！");
          return false;
        }else if(!mailReg.test(this.email_unbind)){
          this.tipshow("邮箱格式不正确！");
          return false;
        }
        email=this.email_unbind;
      }else if(type==2){
        console.log(this.user.email)
        if(this.user.email==null && this.user.email=="" && this.user.email==undefined){
          this.tipshow("邮箱不为空！");
          return false;
        }else if(!mailReg.test(this.user.email)){
          this.tipshow("邮箱格式不正确！");
          return false;
        }
        email=this.user.email;

      }else if(type==3){
        if(this.email_bind==null && this.email_bind=="" && this.email_bind==undefined){
          this.tipshow("邮箱不为空！");
          return false;
        }else if(!mailReg.test(this.email_bind)){
          this.tipshow("邮箱格式不正确！");
          return false;
        }
        email=this.email_bind;

      }
      console.log("email "+email)
       axios.post('https://wenku.qikan.com:11000/admin/lib/sendMailCode.html',qs.stringify({'email':email})
       )
         .then((response)=>{
           console.log("ssss"+response.data);
           let result= response.data;
           if(result.code==1)
           {
             // this.tipshow("验证码发送成功");
             this.auth_time = 60;
             if(type==1){
               this.sendAuthCode=false
             }
             if(type==2){
               this.sendAuthCode1=false

             }
             if(type==3){
               this.sendAuthCode2=false

             }
             var auth_timetimer =  setInterval(()=>{
               this.auth_time--;
               if(this.auth_time<=0){
                 if(type==1){
                   console.log("sss")
                   this.sendAuthCode = true;
                 }
                 if(type==2){
                   this.sendAuthCode1 = true;
                 }
                 if(type==3){
                   this.sendAuthCode2 = true;
                 }

                 clearInterval(auth_timetimer);
               }
             }, 1000);

           }else{
             this.closeWindow();
             this.tipshow(result.message);
           }
         })
         .catch((error)=>{
           console.log(error)
         })

    },
    loaddata(){
      if(this.user.pwd!=null && this.user.pwd!="" && this.user.pwd!=undefined){
        this.pwdstate='已设置'
      }else{
        this.pwdstate='未设置'
      }
      if(this.user.email!=null && this.user.email!="" && this.user.email!=undefined){
        this.unbundemail=this.user.email.substr(0,3)+"****"+this.user.email.substr(7);
        this.haveemail=true;
      }else{
        this.unbundemail='未绑定'
        this.haveemail=false;
      }
      if(this.user.mobile!=null && this.user.mobile!="" && this.user.mobile!=undefined){
        this.bindmobile=this.user.mobile.substr(0,3)+"****"+this.user.mobile.substr(7)
      }else{
        this.bindmobile="未绑定"
      }
      if(this.user.wxopenid!=null && this.user.wxopenid!="" && this.user.wxopenid!=undefined){
        this.unbundwx="("+this.user.wxnick_name+")解绑";
      }else{
        this.unbundwx="绑定";

      }
      if(this.user.qqopenid!=null && this.user.qqopenid!="" && this.user.qqopenid!=undefined){
        this.unbundqq="("+this.user.qqnick_name+")解绑";
      }else{
        this.unbundqq="绑定";
      }
      if(this.user.wbunionid!=null && this.user.wbunionid!="" && this.user.wbunionid!=undefined){
        this.unbundwb="("+this.user.wbnick_name+")解绑";
      }else{
        this.unbundwb="绑定";
      }
    },goUnbind(unbindtype){
      let accountvalue='';
      if(unbindtype==1){
        accountvalue=this.user.wxopenid;
      }else if(unbindtype==2){
        accountvalue=this.user.qqopenid;
      }else if(unbindtype==3){
        accountvalue=this.user.wbunionid;
      }
      axios.post('https://wenku.qikan.com:11000/admin/lib/unbindaccout.html',qs.stringify({'mobile':this.user.mobile,'accountvalue':accountvalue,'unbindtype':unbindtype})
      )
        .then((response)=>{
          console.log(response.data);
          let result= response.data;
          if(result.code==1)
          {
            this.tipshow("解绑成功！");
            // localStorage.removeItem("user");
            // localStorage.setItem("user", JSON.stringify(result.data));
            // this.user=JSON.parse(localStorage.getItem("user"));
            // localStorage.removeItem("user_unique_code");
            // localStorage.setItem("user_unique_code",result.data.unique_code);
            // // localStorage.setItem("user", JSON.stringify(result.data));
            // this.user =result.data;
            localStorage.removeItem("user");
            localStorage.setItem("user",JSON.stringify(result.data));
            this.user =JSON.parse(localStorage.getItem("user"))
            // let v=JSON.stringify(this.user);
            // console.log(this.user)
            // axios.post('https://wenku.qikan.com:11000/admin/lib/removeTokenByUserId.html',qs.stringify({'key':result.data.unique_code}))
            //   .then(function(res){
            //
            //     console.log(res.data.data);
            //   })
            // axios.post('https://wenku.qikan.com:11000/admin/lib/setTokenByUserId.html',qs.stringify({'key':result.data.unique_code,'value':v}))
            //   .then(function(res){
            //     console.log(res.data.data);
            //   })
            this.loaddata();
            this.closeWindow(unbindtype);

          }else{
            this.closeWindow(unbindtype);
            this.tipshow(result.message);
          }
        })
        .catch((error)=>{
          console.log(error)
        })

    },
    toggleShare(){
      this.isShare=!this.isShare;
    },
    zanup(){},
    zandown(){},
// 设置密码
    setPassword(){
     this.isSetPassword=true;
    },
    getQrCode(logintype){

      if(logintype==2){
        if(this.user.qqopenid!=null && this.user.qqopenid!="" && this.user.qqopenid!=undefined){
          this.unbindqq=true;
          return false;
        }
        window.location.href='http://39.98.63.19:12000/admin/lib/qqauthorizationredirect.html?loginType=2'
        // axios.get('https://wenku.qikan.com:11000/admin/lib/qqauthorizationredirect.html',qs.stringify({'loginType':logintype})
        // )
        //   .then((response)=>{
        //     console.log(response.data);
        //     // let result= response.data;
        //     // //this.$router.push({path: result});
        //     // window.location.href=result;
        //   })
        //   .catch((error)=>{
        //     console.log(error)
        //   })
      }else{
        if(logintype==1){
          if(this.user.wxopenid!=null && this.user.wxopenid!="" && this.user.wxopenid!=undefined){
            this.unbindwx=true;
            return false;
          }
        }else if(logintype==3){
          if(this.user.wbunionid!=null && this.user.wbunionid!="" && this.user.wbunionid!=undefined){
            this.unbindwb=true;
            return false;
          }
        }

        axios.post('https://wenku.qikan.com:11000/admin/lib/authorizationredirect.html',qs.stringify({'loginType':logintype})
        )
          .then((response)=>{
            console.log(response.data);
            let result= response.data;
            //this.$router.push({path: result});
            window.location.href=result;
          })
          .catch((error)=>{
            console.log(error)
          })
      }
    },
    goSetPass(){
      // let regExp=/^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,21}$/;
      // let regu = "^[0-9a-zA-Z]{8,10}$";
      // let regExp = new RegExp(regu);
      let regExp = new RegExp(/^(?![^a-zA-Z]+$)(?!\D+$)/);

      console.log("info")
      if(this.newpass==null || this.newpass=="" || this.newpass==undefined){
        console.log("info1")

        this.tipshow("新密码不能为空！");
        return false;
      }else if(this.newpassagain==null || this.newpassagain=="" || this.newpassagain==undefined){
        console.log("info2")

        this.tipshow("请再次输入密码！");
        return false;
      }else if(this.newpass!=this.newpassagain){
        console.log("info3")

        this.tipshow("两次密码输入不一致！");
        return false;
      }else if(!regExp.test(this.newpass) ||!regExp.test(this.newpassagain)|| this.newpass.length<8 || this.newpass.length>10
        || this.newpassagain<8 || this.newpassagain>10){
        console.log("info4")

        this.tipshow("密码格式不正确！");
        return false;
      }else{
        console.log("info5")

        axios.post('https://wenku.qikan.com:11000/admin/lib/setPwd.html',qs.stringify({'mobile':this.user.mobile,'pwd':this.newpass,'pwdAgain':this.newpassagain})
        )
          .then((response)=>{
            console.log(response.data);
            let result= response.data;
            if(result.code==1){
              this.pwdstate='已设置';
              this.isSetPassword=false;
              // localStorage.removeItem("user_unique_code");
              // localStorage.setItem("user_unique_code",result.data.unique_code);
              // // localStorage.setItem("user", JSON.stringify(result.data));
              // this.user =result.data;
              // let v=JSON.stringify(this.user);
              // console.log(this.user)
              // axios.post('https://wenku.qikan.com:11000/admin/lib/removeTokenByUserId.html',qs.stringify({'key':result.data.unique_code}))
              //   .then(function(res){
              //
              //     console.log(res.data.data);
              //   })
              // axios.post('https://wenku.qikan.com:11000/admin/lib/setTokenByUserId.html',qs.stringify({'key':result.data.unique_code,'value':v}))
              //   .then(function(res){
              //     console.log(res.data.data);
              //   })
              localStorage.removeItem("user");
              localStorage.setItem("user",JSON.stringify(result.data));
              this.user =JSON.parse(localStorage.getItem("user"))
              this.tipshow("设置密码成功！")

            }else{
              this.tipshow(result.message)
            }
          })
          .catch((error)=>{
            console.log(error)
          })

        console.log('设置密码成功')
      }


    },

// 绑定手机号
  bindPhone(){
      if (this.havephone==false) {
        this.isBindPhone=true;
      }else{
        this.updatePhone=true;
        this.phonestep1=true;
      }
  },tipshow(e){
      this.tipword=e;
      this.isTip=true;
      setTimeout(() => {
        this.tipword='';
        this.isTip=false;
      }, 2000);
    },
  goBindPhone(){
    console.log('绑定手机号后，显示绑定成功')
  },
  updatePhone1(){ //验证手机号
    if(this.phonecode==null || this.phonecode=="" || this.phonecode==undefined){
      this.tipshow("验证码不能为空")
      return false;
    }else{
      axios.post('https://wenku.qikan.com:11000/admin/lib/checkMobile.html',qs.stringify({'mobile':this.user.mobile,'validcode':this.phonecode})
      )
        .then((response)=>{
          console.log(response.data);
          let result= response.data;
          if(result.code==1){
            this.phonestep1=false;
            this.phonestep2=true;
            this.phonecode='';
          }else{
            this.tipshow("设置密码失败！")
          }
        })
        .catch((error)=>{
          console.log(error)
        })
    }
  },
    updatePhone2(){ //更新新手机号
      var mobilereg = /^1[345789]\d{9}$/;

      console.log("ssass"+this.phone_bind+" "+this.phonecode_bind)
      if(this.phone_bind==null || this.phone_bind=="" || this.phone_bind==undefined){
        console.log("1");
        this.tipshow("手机号不能为空")
        return false;
      }else if(this.phonecode_bind==null || this.phonecode_bind=="" || this.phonecode_bind==undefined){
        console.log("2");
        this.tipshow("验证码不能为空")
        return false;
      }else if(!mobilereg.test(this.phone_bind)){
        console.log("3")
        this.tipshow("手机格式不正确！")
        return false;
      }else{
        console.log("hahhhh")
        axios.post('https://wenku.qikan.com:11000/admin/lib/editMsg.html',qs.stringify({'editType':200,'mobile':this.user.mobile,'newmobile':this.phone_bind,'validcode':this.phonecode_bind})
        )
          .then((response)=>{
            console.log(response.data);
            let result= response.data;
            if(result.code==1){
              // localStorage.removeItem("user_unique_code");
              // localStorage.setItem("user_unique_code",result.data.unique_code);
              // // localStorage.setItem("user", JSON.stringify(result.data));
              // this.user =result.data;
              // let v=JSON.stringify(this.user);
              // console.log(this.user)
              // axios.post('https://wenku.qikan.com:11000/admin/lib/removeTokenByUserId.html',qs.stringify({'key':result.data.unique_code}))
              //   .then(function(res){
              //
              //     console.log(res.data.data);
              //   })
              // axios.post('https://wenku.qikan.com:11000/admin/lib/setTokenByUserId.html',qs.stringify({'key':result.data.unique_code,'value':v}))
              //   .then(function(res){
              //     console.log(res.data.data);
              //   })
              localStorage.removeItem("user");
              localStorage.setItem("user",JSON.stringify(result.data));
              this.user =JSON.parse(localStorage.getItem("user"))
              this.phonestep2=false;
              this.updatePhone=false;
              this.phone_bind='';
              this.phonecode_bind='';
              this.bindmobile=this.user.mobile.substr(0,3)+"****"+this.user.mobile.substr(7);
            }else{
              this.tipshow(result.message)
            }
          })
          .catch((error)=>{
            console.log(error)
          })
      }
    },



// 绑定邮箱
 bindEmail(){
      if (this.haveemail==false) {
        this.isBindEmail=true;
      }else{
        this.updateEmail=true;
        this.emailstep1=true;
      }
  },
 goBindEmail(){
    console.log('绑定手机号后，显示绑定成功')
   axios.post('https://wenku.qikan.com:11000/admin/lib/bindemail.html',qs.stringify({'msg':this.emailcode_unbind,'mobile':this.user.mobile,'email':this.email_unbind})
   )
     .then((response)=>{
       console.log(response.data);
       let result= response.data;
       if(result.code==1){
        this.isBindEmail=false;
         // localStorage.removeItem("user_unique_code");
         // localStorage.setItem("user_unique_code",result.data.unique_code);
         // // localStorage.setItem("user", JSON.stringify(result.data));
         // this.user =result.data;
         localStorage.removeItem("user");
         localStorage.setItem("user",JSON.stringify(result.data));
         this.user =JSON.parse(localStorage.getItem("user"))
         // let v=JSON.stringify(this.user);
         // console.log(this.user)
         // axios.post('https://wenku.qikan.com:11000/admin/lib/removeTokenByUserId.html',qs.stringify({'key':result.data.unique_code}))
         //   .then(function(res){
         //
         //     console.log(res.data.data);
         //   })
         // axios.post('https://wenku.qikan.com:11000/admin/lib/setTokenByUserId.html',qs.stringify({'key':result.data.unique_code,'value':v}))
         //   .then(function(res){
         //     console.log(res.data.data);
         //   })
         this.loaddata();
       }else{
         this.tipshow("绑定邮箱失败！")
       }
     })
     .catch((error)=>{
       console.log(error)
     })
  },
  updateEmail1(){ //验证邮箱
    let mailReg = /^([0-9A-Za-z\-_\.]+)@([0-9a-z\-]+\.[a-z]{2,3}(\.[a-z]{2})?)$/g;

        if(this.user.email==null && this.user.email=="" && this.user.email==undefined){
          this.tipshow(" 邮箱不能为空！")
          return false;
        }else if(!mailReg.test(this.user.email)){
          consolr.log("info"+this.user.email)
          this.tipshow(" 邮箱格式不正确！")
          return false;
        }else if(this.emailcode==null && this.emailcode=="" && this.emailcode==undefined){
          this.tipshow("验证码不能为空！");
          return false;
        }

    axios.post('https://wenku.qikan.com:11000/admin/lib/checkEmailCode.html',qs.stringify({'email':this.user.email,'msg':this.emailcode})
    )
      .then((response)=>{
        console.log(response.data);
        let result= response.data;
        if(result.code==1)
        {
          this.emailstep1=false;
          this.emailstep2=true;
        }else{
          this.tipshow(result.message);
        }
      })
      .catch((error)=>{
        console.log(error)
      })

  },
  updateEmail2(){ //更新邮箱
    let mailReg = /^([0-9A-Za-z\-_\.]+)@([0-9a-z\-]+\.[a-z]{2,3}(\.[a-z]{2})?)$/g;

    if(this.emailcode_bind==null || this.emailcode_bind=="" || this.emailcode_bind==undefined ){
      this.tipshow("验证码不能为空！");
      return false;
    }
    if(this.email_bind==null || this.email_bind=="" || this.email_bind==undefined ){
      this.tipshow("绑定邮箱不能为空！");
      return false;
    }
    if(this.emailcode_bind==null || this.emailcode_bind=="" || this.emailcode_bind==undefined ){
      this.tipshow("验证码不能为空！");
      return false;
    }
    if(!mailReg.test(this.email_bind)){
      this.tipshow(" 邮箱格式不正确！")
      return false;
    }
    axios.post('https://wenku.qikan.com:11000/admin/lib/bindemail.html',qs.stringify({'msg':this.emailcode_bind,'mobile':this.user.mobile,'email':this.email_bind})
    )
      .then((response)=>{
        console.log(response.data);
        let result= response.data;
        if(result.code==1){
          this.updateEmail=false;
          this.phonestep2=false;
          this.emailstep2=false;
          localStorage.removeItem("user");
          localStorage.setItem("user",JSON.stringify(result.data));
          this.user =JSON.parse(localStorage.getItem("user"))
          // let v=JSON.stringify(this.user);
          // console.log(this.user)
          // axios.post('https://wenku.qikan.com:11000/admin/lib/removeTokenByUserId.html',qs.stringify({'key':result.data.unique_code}))
          //   .then(function(res){
          //
          //     console.log(res.data.data);
          //   })
          // axios.post('https://wenku.qikan.com:11000/admin/lib/setTokenByUserId.html',qs.stringify({'key':result.data.unique_code,'value':v}))
          //   .then(function(res){
          //     console.log(res.data.data);
          //   })
          this.loaddata();
        }else{
          this.tipshow(result.message)
        }
      })
      .catch((error)=>{
        console.log(error)
      })
  },

//关闭窗口


},
}
</script>

<style scoped>
.hmenu{border-bottom:1px solid #F0F2F7; width: 100%; height: 52px; clear: both; padding:0 15px;}
.hmenu a{color:#1A1A1A; line-height: 50px; height: 50px; width: 70px; margin-right: 43px; display: inline-block; font-weight: 600;}
.on{ color: #225599 !important; border-bottom: 3px solid #0084FF;}
.list66{ width: 100%; height: 66px; border-bottom: 1px solid #ebebeb; font-size: 14px; padding: 0 21px 0 27px; }
.list66 .aa{ width: 50%; height: 65px; display: inline-block; float: left; }
.list66 .aa .a1{ width: 100%; height: 35px;color: #1a1a1a; line-height: 45px; font-weight: 600; }
.list66 .aa .a2{ width: 100%; height: 20px;color: #8792A7; line-height: 20px;}
.list66 .bb{ width: 50%; height: 65px; display: inline-block; float: left; line-height: 65px; color: #0084FF; text-align: right; }

.list147{ width: 100%; height: 147px; border-bottom: 1px solid #ebebeb; font-size: 14px; padding: 0 21px 0 27px; }
.list147 .w1{ width: 100%; height: 24px; margin: 12px 0 15px;color: #1a1a1a; line-height: 24px; font-weight: 600; }
.list147 .w2{width: 100%; height: 27px; line-height: 27px;color: #168AFF;}
.list147 .w2 span{height: 27px; line-height: 27px; display: inline-block; margin-right:30px;}
.list147 .w2 span img{ display: inline-block; vertical-align: middle;  }




.mask{ width: 100%; height: 100%; background: rgba(24,24,24,0.50); position: fixed;z-index: 999; left: 0; top: 0; }
/* 设置窗口 */
.forgetbox{ width: 380px; height: auto; overflow: hidden; position: fixed; z-index:1000; left: calc( 50% - 190px ); top: calc( 50% - 200px ); background-color: #fff; padding: 30px 40px 24px 36px;}
.forgetbox .close{ position: absolute;z-index: 1001; width: 32px; height: 32px; background: url('../../assets/images/icon-close.png') center center no-repeat; background-size: 14px 14px; top:10px; right:10px;}

.ffnextbtn{width: 100%; height: 40px; line-height: 40px; background-color: #0084FF;border-radius: 3px;font-size: 14px; color: #fff; text-align: center;margin-top:60px;}
.fftitle{ width: 100%; line-height: 30px; font-size: 16px; color: #1a1a1a; font-weight: 600; }
.ffdec{width: 100%; line-height: 18px; font-size: 12px; color: #8590A6;}
.ffbox{ height: 60px; border-bottom: 1px solid #ebebeb; padding: 24px 0 10px; width: 100%; position: relative; }
.ffbox .ffinputtext{ width: 100%; line-height: 28px; height: 28px; outline: none; border: none; color: #8590A6; text-align: left;font-size: 16px; }
.ffbox .ffyanzheng{position: absolute;z-index: 1001; top:23px; right:0;color: #175199;font-size: 16px;}
.ffok{border: 1px solid #EBEBEB;border-radius: 3px;height: 40px; line-height: 40px; width: 100%;font-size: 16px;color: #1a1a1a; text-align: center;}
.ffok img{ width: 20px; height: 20px; vertical-align: middle; margin-right: 10px; display: inline-block; }


.jb3{ width: 550px; height: auto; overflow: hidden; position: fixed; z-index:1000; left: calc( 50% - 275px ); top: calc( 50% - 200px ); background-color: #fff; padding: 44px 60px 57px; text-align: center;}
.jb3 .jbtitle{ width: 100%; line-height: 50px; font-size: 30px; color: #1a1a1a; font-weight: 600; }
.jb3 .jbdec{width: 100%; line-height: 30px; font-size: 16px; color: #1a1a1a; margin-top:20px;}
.jb3 .jbbtn{ width: 100%; height: 42px; clear: both;margin-top: 60px; text-align: center; font-size: 16px;}
.jb3 .jbbtn .a1{width: 204px; height: 42px; line-height: 40px; border: 2px solid #C6C7CC;border-radius: 4px; display: inline-block;float: left; color:#88909E;}
.jb3 .jbbtn .a2{width: 204px; height: 42px; line-height: 42px;  background: #0084FF;border-radius: 4px; display: inline-block;float: right;color: #fff; }
.tipinfo{position: fixed; z-index: 9999; top: 50%; left: 50%; width: 400px;  height: 40px;border-radius: 10px; margin-left: -200px; margin-top: -20px; line-height: 40px;text-align: center;color: #fff; font-size: 14px; background-color: rgba(50,50,50,0.8)}

</style>
